/**
 * Created with  SublimeText
 * @Author:      Lyle
 * @DateTime:    2017-01-17 23:03:55
 * @Description: 
 */

import React, { Component, PropTypes } from 'react'

class AdminUserList extends Component {

    constructor(props) {
        super(props);
        this.props.init();
    }

    getItems(arr) {
        var items = [];
        for (var i in arr) {
            items[i] = (
                <li key={i}><span>{arr[i].id}</span><span>{arr[i].username}</span><span>{arr[i].title}</span><span>{arr[i].rules}</span></li>
            );
        }
        return items;
    }

    loading() {
        return <li>loading</li>;
    }

    render() {
        let arr = this.props.adminUserListState.arr;
        let items = arr.length > 0 ? this.getItems(this.props.adminUserListState.arr) : this.loading();
        return (
            <div id='adminUserList' className='module'>
                <div className='tableName'>
                    AdminUserTable
                </div>
                <div className='table'>
                    {items}
                </div>
            </div>
        )
    }
}

export default AdminUserList
